package com.example.ecommerce.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.ecommerce.entity.ProductCategory;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Param;

@Mapper
public interface ProductCategoryMapper extends BaseMapper<ProductCategory> {
    /**
     * 统计分类下的商品数量
     */
    @Select("SELECT COUNT(*) FROM products WHERE category_id = #{categoryId} AND status = 1 AND is_deleted = 0")
    Long countProducts(@Param("categoryId") Long categoryId);
} 